﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using MoneyLover.WCFMoneyLover;

namespace MoneyLover.Pages
{
    public partial class Sono : PhoneApplicationPage
    {
        public Sono()
        {
            InitializeComponent();
        }
        MoneyLoverServiceClient _db = new MoneyLoverServiceClient();
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            LoadReference();
        }

        private void LoadReference()
        {
            _db.GetListNoChuaTraCompleted += _db_GetListNoChuaTraCompleted;
            _db.GetListNoChuaTraAsync(Contanst._tkdangnhap.USERNAME);
            _db.GetListNoDaTraCompleted += _db_GetListNoDaTraCompleted;
            _db.GetListNoDaTraAsync(Contanst._tkdangnhap.USERNAME);
            _db.GetListVayChuaTraCompleted += _db_GetListVayChuaTraCompleted;

            _db.GetListVayChuaTraAsync(Contanst._tkdangnhap.USERNAME);
            _db.GetListVayDaTraCompleted += _db_GetListVayDaTraCompleted;
            _db.GetListVayDaTraAsync(Contanst._tkdangnhap.USERNAME);
        }

        void _db_GetListVayDaTraCompleted(object sender, GetListVayDaTraCompletedEventArgs e)
        {
            if (e.Result!=null)
            {
                listchovaydatra.ItemsSource = e.Result;
            }
        }

        void _db_GetListVayChuaTraCompleted(object sender, GetListVayChuaTraCompletedEventArgs e)
        {
            if (e.Result != null)
            {
                listchovaychuatra.ItemsSource = e.Result;
            }
            
        }

        void _db_GetListNoDaTraCompleted(object sender, GetListNoDaTraCompletedEventArgs e)
        {
            if (e.Result != null)
            {
                listNodatra.ItemsSource = e.Result;
            }
        }

        void _db_GetListNoChuaTraCompleted(object sender, GetListNoChuaTraCompletedEventArgs e)
        {
            if (e.Result != null)
            {
                listNochuatra.ItemsSource = e.Result;
            }
        }

        private void imagevaychuatra_MouseEnter(object sender, MouseEventArgs e)
        {
            if (listchovaychuatra.Visibility==Visibility.Collapsed)
            {
                listchovaychuatra.Visibility = Visibility.Visible;
            }
            else
            {
                listchovaychuatra.Visibility = Visibility.Collapsed;
            }
        }

        private void imagevaydatra_MouseEnter(object sender, MouseEventArgs e)
        {
            if (listchovaydatra.Visibility == Visibility.Collapsed)
            {
                listchovaydatra.Visibility = Visibility.Visible;
            }
            else
            {
                listchovaydatra.Visibility = Visibility.Collapsed;
            }
        }

        private void imagenochuatra_MouseEnter(object sender, MouseEventArgs e)
        {
            if (listNochuatra.Visibility == Visibility.Collapsed)
            {
                listNochuatra.Visibility = Visibility.Visible;
            }
            else
            {
                listNochuatra.Visibility = Visibility.Collapsed;
            }
        }

        private void imagenodatra_MouseEnter(object sender, MouseEventArgs e)
        {
            if (listNodatra.Visibility == Visibility.Collapsed)
            {
                listNodatra.Visibility = Visibility.Visible;
            }
            else
            {
                listNodatra.Visibility = Visibility.Collapsed;
            }
        }
    }
}